﻿///-----------------------------------------------
///-----------------------------------------------
//全局JS
//------------------------------------------------
//------------------------------------------------
var app = angular.module('app', []);
//app.config(function ($locationProvider) {
//    //$locationProvider.html5Mode({ enabled: true, requireBase: false });
//    $locationProvider.html5Mode(true);//启用html5路由模式
//})



//界面跳转管理-地址连接
app.controller('AllLinkCtrl', ['$scope','$http', '$window', function ($scope,$http, $window) {

    //首页
    $scope.gotoHome = function () {
        //alert("首页");
        $window.location.href = "/Home/Index";
    }
    //我的订单列表页面
    $scope.gotoOrderList = function () {
        //alert("我的订单列表页面");
        $window.location.href = "/Order/OrderList";
    }
    //我的信息页
    $scope.gotoInformation = function () {
        //alert("我的信息页");
        $window.location.href = "/Information/Index";
    }

    //我的钱包页面
    $scope.gotoMyWalt = function () {
        //alert("我的钱包页面");
        $window.location.href = "/Information/MyWalt";
    }
    //地址管理
    $scope.gotoAddress = function (data) {
        //alert("地址管理");
        $window.location.href = "/Information/Address?shopnumber=" + data;
    }
    //我的积分页面
    $scope.gotoIntegral = function () {
        //alert("我的积分页面");
        $window.location.href = "/Information/Integral";
    }
    //订单详情页
    $scope.gotoOrderDetail = function (data) {
        $window.location.href = "/Order/OrderDetail?FormID=" + data;
    }
    //订单评论页
    $scope.togoEvaluate = function (data) {
        $window.location.href = "/Order/Evaluate?FormID=" + data;
    }

    $scope.togoSelectAddress = function () {
        //截取url数据方法
        var getParam = function (name) {
            var search = document.location.search;
            //alert(search);
            var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
            var matcher = pattern.exec(search);
            var items = null;
            if (null != matcher) {
                try {
                    items = decodeURIComponent(decodeURIComponent(matcher[1]));
                } catch (e) {
                    try {
                        items = decodeURIComponent(matcher[1]);
                    } catch (e) {
                        items = matcher[1];
                    }
                }
            }
            return items;
        };
        //var a = getParam('shopnumber');
        //alert(a);
        if (document.getElementById("Address").text.trim() != "" && document.getElementById("Address").text.trim() != null && document.getElementById("Address").text.trim() != "点击添加送餐地址") {
            $window.location.href = "/Information/SelectAdd?shopnumber=" + getParam('shopnumber');
        }
        else {
            $window.location.href = "/Information/Address?shopnumber=" + getParam('shopnumber');

        }
    }
}]);